package cn.south.campus.admin.campus.controller;

import cn.south.campus.admin.campus.model.req.AuditReq;
import cn.south.campus.admin.campus.model.req.UserReq;
import cn.south.campus.admin.campus.model.vo.StudentVo;
import cn.south.campus.admin.campus.model.vo.UserVo;
import cn.south.campus.admin.campus.service.StudentService;
import cn.south.campus.admin.campus.service.UserService;
import cn.south.campus.common.model.bo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2024/11/13 11:07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/campus/user")
public class UserController {

    private final UserService userService;

    private final StudentService studentService;

    @GetMapping("page")
    public Result<IPage<UserVo>> page(UserReq userReq) {
        return Result.success(userService.selectPage(userReq));
    }

    @GetMapping("showAuthInfo/{id}")
    public Result<StudentVo> getAuthInfo(@PathVariable Long id) {
        return Result.success(studentService.getAuth(id));
    }

    @PutMapping("audit")
    public Result<String> audit(@RequestBody AuditReq req) {
        studentService.audit(req);
        return Result.success("操作成功");
    }
}
